package com.ruoyi.common.enums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.RequiredArgsConstructor;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 配饰枚举值  腰带、毛领、帽子、袖带、包装袋/盒、内胆、遗留物、其它
 */
@RequiredArgsConstructor
@Getter
@AllArgsConstructor
public enum AccessoriesEnum {
    //腰带
    BELT("belt","腰带"),

    FUR_COLLAR("fur_collar","毛领"),
    //帽子
    HAT("hat","帽子"),
    //袖带
    CUFF("cuff","袖带"),
    PACKAGING_BAG("packagingBag","包装袋/盒"),

    INNER_LINER("inner_liner","内胆"),
    RELIC("relic","遗留物"),
    OTHER("other","其它");

    @JsonValue
    private String code;
    @EnumValue
    private String desc;

    /**
     * 根据code获取枚举
     * @param code
     * @return
     */
    @JsonCreator
    public static AccessoriesEnum getByCode(String code) {
        for (AccessoriesEnum value : values()) {
            if (value.code.equals(code)) {
                return value;
            }
        }
        return null;
    }

    /**
     * 获取枚举列表
     * @return
     */
    public static List<Map<String,String>>   getList(){
        Arrays.stream(values()).map(value -> {
            Map<String,String> map = new HashMap<>();
            map.put("code",value.code);
            map.put("desc",value.desc);
            return map;
        }).collect(Collectors.toList());
    	return null;
    }
}
